package se.lnu.axez.textures;

import se.lnu.axez.shaders.ShaderProgram;
import android.opengl.GLES20;

public abstract class Texture {
	private static final String UNI_TEXTURE = "u_texture"; 
	
	Texture() {};
	
	abstract void load();
	
	abstract void release();
	
	protected abstract int getTextureID();
	
	public void use(ShaderProgram shaderProgram) {
		int uniID = shaderProgram.getUniformID(UNI_TEXTURE);
		if (uniID != ShaderProgram.INVALID_ID) {
			GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
			GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, this.getTextureID());
			GLES20.glUniform1i(uniID, 0);
		}
	}
}
